package com.example.mall.user.svc.infr.constants;

import com.example.mall.common.constants.BaseEnum;
import com.example.mall.common.constants.CodeEnum;
import com.example.mall.common.exception.BizException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Optional;

/**
 * 绑定类型
 *
 * @author Mickey
 * @since 2022/4/19
 **/
@Getter
@AllArgsConstructor
public enum BindType implements BaseEnum<BindType> {

    //绑定手机
    MOBILE(0, "mobileBind"),
    ;

    private final Integer code;
    private final String name;

    public static BindType of(Integer code) {
        return Optional
                .ofNullable(BaseEnum.parseByCode(BindType.class, code))
                .orElseThrow(() -> new BizException(CodeEnum.FAIL));
    }
}
